using System;
using UnityEngine;
using QFramework;

namespace QFramework.Monk
{
	public partial class Exp : PowerUp
	{
		protected override void Execute()
		{
			if ( mConfigModel.CheckCanLevelUp(AppStart.level.Value))
			{
				
				AudioKit.PlaySound("exp");
				AppStart.exp.Value++;
				var nextLevelConfig = mConfigModel.GetLevelUpConfig(AppStart.level.Value+1);
				//是否达到升级条件
				if (AppStart.exp.Value>=nextLevelConfig.NeedExp)
				{
					AppStart.exp.Value = 0;
					AppStart.level.Value++;
				}
			}

			this.gameObject.DestroySelfGracefully();
		}

		protected override bool CanTriggerFly()
		{
			//是否已经是最大等级
			return mConfigModel.CheckCanLevelUp(AppStart.level.Value);
		}
	}
}
